package com.jr.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jr.entity.Myapplyjob;
import com.jr.entity.Uptable;
import com.jr.service.MyapplyjobService;
import com.jr.service.impl.UptableServiceImpl;
import com.jr.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
public class UptableController {
    @Autowired
    private UptableServiceImpl uptableService;
    @Autowired
    private MyapplyjobService myapplyjobService;
    @RequestMapping("/finduptable")
    public boolean fuptable(Uptable uptable){
        ArrayList<Uptable> list=uptableService.findbyuids(uptable);
        if (list.size()>0){
            return true;
        }
        else {
            return false;
        }
    }
    @RequestMapping("/adduptable")
    public boolean adduptable(Uptable uptable){
        boolean b=uptableService.addups(uptable);
        return b;
    }
/*    @RequestMapping("/findmyapplyjob")
    private Result myjob(Post post, Integer indexpage, Integer uid){
        if (indexpage==null){
            PageHelper.startPage(1,2);
        }else {
            PageHelper.startPage(indexpage,2);
        }
        Uptable uptable=new Uptable();
        uptable.setUid(uid);
        uptable.setPost(post);
        ArrayList<Uptable> list=uptableService.myapplyjobs(uptable);
        PageInfo<Uptable> info=new PageInfo<>(list);
        return Result.success(info);
    }*/

    @RequestMapping("/findmyapplyjob")
    private Result myjob(String pname, Integer indexpage, Integer uid){
        if (indexpage==null){
            PageHelper.startPage(1,2);
        }else {
            PageHelper.startPage(indexpage,2);
        }
        Myapplyjob myapplyjob=new Myapplyjob();
        myapplyjob.setUid(uid);
        myapplyjob.setPname(pname);


        ArrayList<Myapplyjob> list=myapplyjobService.myapplyjob(myapplyjob);
        PageInfo<Myapplyjob> info=new PageInfo<>(list);

        return Result.success(info);
    }


}
